$_COOKIE['cookiefoo'], try to get a cookie

Posted by Felix Guerrero on Stack Overflow See other posts from Stack Overflow or by Felix Guerrero
Published on 2010-05-25T14:16:43Z Indexed on 2010/05/25 14:21 UTC
Read the original article Hit count: 154

Filed under:
|
|
|

Hi, I'm newbie with webapps and PHP.

I'm trying to get a cookie that it's not created yet, I mean, when I try to load a page that looks for a inexistent cookie I get an error, I tried to get rid of this with a try/catch but not success. This this the code I'm trying:

try{

    $cookie =  $_COOKIE['cookiefoo'];

    if($cookie){

          //many stuffs here
    }
    else
        throw new Exception("there is not a cookie"); 
}
catch(Exception $e){

}

How can I achieve this, any ideas, it would be appreciated it.

© Stack Overflow or respective owner

Related posts about php

Related posts about cookies